home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / jikes-1.02 / src / double.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-06  |  4.3 KB  |  142 lines

  1. // $Id: double.h,v 1.4 1999/07/06 13:49:19 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef Double_INCLUDED
  11. #define Double_INCLUDED
  12.  
  13. #include "config.h"
  14. #include <math.h>
  15.  
  16. class LongInt;
  17. class IEEEdouble;
  18. class IEEEfloat
  19. {
  20.     protected:
  21.         union
  22.         {
  23.             float float_value;
  24.             u4 word;
  25.         } value;
  26.  
  27.     public:
  28.  
  29.         u4 &Word() { return value.word; }
  30.         float &FloatValue() { return value.float_value; }
  31.  
  32.         IEEEfloat(float);
  33.         IEEEfloat(u4);
  34.  
  35.         IEEEfloat(i4);
  36.         IEEEfloat(char *);
  37.         IEEEfloat(IEEEdouble a);
  38.  
  39.         inline IEEEfloat (void) {}
  40.  
  41.         IEEEfloat  operator+  (IEEEfloat); // binary addition
  42.         IEEEfloat  operator+  ();         // unary plus
  43.         IEEEfloat& operator+= (IEEEfloat); // add and assign
  44.  
  45.         IEEEfloat  operator-  (IEEEfloat); // binary subtraction
  46.         IEEEfloat  operator-  ();         // unary minus
  47.         IEEEfloat& operator-= (IEEEfloat); // subtract and assign
  48.  
  49.         IEEEfloat  operator* (IEEEfloat);  // multiplication
  50.         IEEEfloat& operator*=(IEEEfloat);  // multiply and assign
  51.  
  52.         IEEEfloat  operator/ (IEEEfloat);  // divide
  53.         IEEEfloat& operator/=(IEEEfloat);  // divide and assign
  54.  
  55.         bool      operator== (IEEEfloat); // equal
  56.         bool      operator!= (IEEEfloat); // not equal
  57.  
  58.         bool  operator<  (IEEEfloat); // less-than
  59.         bool  operator>  (IEEEfloat); // greater-than
  60.         bool  operator<= (IEEEfloat); // less-than or equal
  61.         bool  operator>= (IEEEfloat); // greater-than or equal
  62.  
  63.         int IntValue();
  64.         int LongValue();
  65.  
  66.         static void Fmodulus(IEEEfloat, IEEEfloat, IEEEfloat&);
  67.         static void Divide(IEEEfloat, IEEEfloat, IEEEfloat &, IEEEfloat &);
  68.         void String(char *);
  69. };
  70.  
  71.  
  72. class IEEEdouble
  73. {
  74. protected:
  75.     union
  76.     {
  77.         double double_value;
  78.         u4 word[2];
  79.     } value;
  80.  
  81. public:
  82.  
  83. #ifdef BIGENDIAN
  84.     u4 &HighWord() { return value.word[0]; }
  85.     u4 &LowWord()  { return value.word[1]; }
  86. #else
  87.     u4 &LowWord()  { return value.word[0]; }
  88.     u4 &HighWord() { return value.word[1]; }
  89. #endif
  90.  
  91.     double &DoubleValue() { return value.double_value; }
  92.  
  93.     static IEEEdouble min_long;
  94.  
  95.     //
  96.     //     static inline IEEEdouble NaN()               { return  zero / zero; }
  97.     //     static inline IEEEdouble POSITIVE_INFINITY() { return  1.0  / zero; }
  98.     //     static inline IEEEdouble NEGATIVE_INFINITY() { return -1.0  / zero; }
  99.     //
  100.     static inline IEEEdouble NaN()               { return  IEEEdouble(0x7fffffff, 0xffffffff); }
  101.     static inline IEEEdouble POSITIVE_INFINITY() { return  IEEEdouble(0x7ff00000, 0x00000000); }
  102.     static inline IEEEdouble NEGATIVE_INFINITY() { return  IEEEdouble(0xfff00000, 0x00000000); }
  103.  
  104.     IEEEdouble(LongInt&);
  105.     IEEEdouble(double);
  106.     IEEEdouble(u4, u4);
  107.     IEEEdouble(u4);
  108.     IEEEdouble(IEEEfloat);
  109.     IEEEdouble(i4);
  110.     IEEEdouble(char *);
  111.     inline IEEEdouble (void) {}
  112.  
  113.     IEEEdouble  operator+  (IEEEdouble); // binary addition
  114.     IEEEdouble  operator+  ();         // unary plus
  115.     IEEEdouble& operator+= (IEEEdouble); // add and assign
  116.  
  117.     IEEEdouble  operator-  (IEEEdouble); // binary subtraction
  118.     IEEEdouble  operator-  ();         // unary minus
  119.     IEEEdouble& operator-= (IEEEdouble); // subtract and assign
  120.  
  121.     IEEEdouble  operator* (IEEEdouble);  // multiplication
  122.     IEEEdouble& operator*=(IEEEdouble);  // multiply and assign
  123.  
  124.     IEEEdouble  operator/ (IEEEdouble);  // divide
  125.     IEEEdouble& operator/=(IEEEdouble);  // divide and assign
  126.  
  127.     bool  operator== (IEEEdouble); // equal
  128.     bool  operator!= (IEEEdouble); // not equal
  129.     bool  operator<  (IEEEdouble); // less-than
  130.     bool  operator>  (IEEEdouble); // greater-than
  131.     bool  operator<= (IEEEdouble); // less-than or equal
  132.     bool  operator>= (IEEEdouble); // greater-than or equal
  133.  
  134.     inline int IntValue() { return (int) DoubleValue(); }
  135.     void String(char *);
  136.  
  137.     static void Divide(IEEEdouble, IEEEdouble, IEEEdouble &);
  138.     static void Fmodulus(IEEEdouble, IEEEdouble, IEEEdouble &);
  139. };
  140.  
  141. #endif
  142.